package com.victualler.core.config.permission.controller.impl;

import com.victualler.core.base.controller.impl.BaseRestControllerImpl;
import com.victualler.core.common.dto.PageDto;
import com.victualler.core.config.permission.controller.RoleInfoController;
import com.victualler.core.config.permission.dto.RoleGroupDto;
import com.victualler.core.config.permission.dto.request.RoleRequestDto;
import com.victualler.core.config.permission.entity.RoleInfoDao;
import com.victualler.core.config.permission.repository.RoleInfoQueryRepository;
import com.victualler.core.config.permission.repository.RoleInfoRepository;
import com.victualler.core.config.permission.service.RoleInfoService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Guoshichang
 * @discription:    
 */
@RestController
@RequestMapping("/core/config/permission/role")
public class RoleInfoControllerImpl extends BaseRestControllerImpl<RoleInfoDao,RoleInfoRepository,RoleInfoQueryRepository,RoleInfoService> implements RoleInfoController {

    /**
     * @author Guoshichang
     * @since 13:39 on 2018/7/7.
     * @param roleRequestDto
     * @Function  根据条件入参PermissionRequestDto动态分页查询权限
     */
    @RequestMapping("getByRequestDto")
    @Override
    public PageDto<RoleInfoDao> getByRequestDto(@RequestBody RoleRequestDto roleRequestDto, @RequestParam("pageNo") int pageNo, @RequestParam("limit")  int limit) {
        return this.baseService.getByRequestDto(roleRequestDto,pageNo,limit);
    }
    /**
     * @author Guoshichang
     * @since 23:06 on 2018/9/18.
     * @param userId 用户id
     * @return RoleGroupDto
     * @Function  获取用户对应的 角色列表和未在列的角色列表
     */
    @RequestMapping("/getByUserId")
    public RoleGroupDto getByUserId(@RequestParam("userId") Long userId) {
        return this.baseService.getByUserId(userId);
    }

}
